package com.phyane.bbs.service;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import com.phyane.bbs.param.BbsUserParam;
import com.phyane.common.baseopp.DataBaseOpp;

public class BbsLoginService {
	
	public boolean login(BbsUserParam user){
		boolean result = false;
		String sql = "";
		Statement st = null;
		ResultSet rst = null;
		int count = 0;
		try {
			Connection conn = DataBaseOpp.getConnection();
			st = conn.createStatement();
			sql = "select count(*) as count from phyane_bbs_user where name='"+user.getName()+
				"' and passwd='"+user.getPasswd()+"'";
			rst = st.executeQuery(sql);
			if(rst != null){
				while(rst.next()){
					count = rst.getInt("count");
				}
			}
			if(count == 1){
				result = true;
			}else{
				result = false;
			}
		} catch (Exception e) {
			result = false;
		}
		return result;
	}
	
	public boolean addUser(BbsUserParam user){
		
		return false;
	}
}
